package cn.clwxy.gdz.service;

import cn.clwxy.gdz.bo.AdminArticlePageBean;
import cn.clwxy.gdz.dao.AdminArticleDao;
import cn.clwxy.gdz.dao.AdminArticleDaoimp;
import cn.clwxy.gdz.entity.AdminArticle;

public class AdminArticleServiceimp implements AdminArticleService{
	AdminArticleDao aad=new AdminArticleDaoimp();
	@Override
	public AdminArticlePageBean getArticlePageBean(Integer pageNo,AdminArticle article) {
		AdminArticlePageBean aap=new  AdminArticlePageBean();
		int totalCount=aad.getColumns(article).intValue();
		int totalPage=totalCount%15==0?totalCount/15:totalCount/15+1;
		aap.setArticles(aad.getArticles(pageNo, article));
		aap.setFirstPage(1);
		aap.setLastPage(totalPage);
		aap.setPrePage(pageNo-1<0?1:pageNo-1);
		aap.setNextPage(pageNo+1>totalPage?totalPage:pageNo+1);
		aap.setTotalCount(totalCount);
		aap.setTotalPage(totalPage);
		return null;
	}

	@Override
	public int addArticle(AdminArticle article) {
		aad.addArticle(article);
		return 0;
	}

	@Override
	public int updateArticle(AdminArticle article) {
		aad.updateArticle(article);
		return 0;
	}
	

}
